<%--
  Created by IntelliJ IDEA.
  User: phj
  Date: 2020/2/4
  Time: 15:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<h3>springmvc</h3>
<a href="/hello">springmvc</a>
<button onclick="get()">GET</button>
<button onclick="post()">POST</button>
<button onclick="put()">PUT</button>
<button onclick="del()">DELETE</button>

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script type="text/javascript">
    function get() {
        $.ajax({
            type: "GET",
            url: "/score/2",
            success: function (data) {
                window.alert(data);
            }
        })
    }

    function post() {
        $.ajax({
            type: "POST",
            url: "/score",
            data: {
                name: "小白",
                book: "英语",
                score: 98
            },
            success: function (res) {
                window.alert(res);
            }
        })
    }

    function put() {
        $.ajax({
            type: "PUT",
            url: "/score/59/2",
            success: function (res) {
                window.alert(res);
            }
        })
    }

    function del() {
        $.ajax({
            type: "DELETE",
            url: "/score/6",
            success: function (res) {
                window.alert(res);
            }
        })
    }
</script>
</body>
</html>
